<!-- 首页 -->
<template>
	<view class="container">
		<view class="c-form" @click="toOrgRecruitDetail">
			<view class="form-info">
				<u-form :model="orgInfo" label-width="100" label-position="top">
					<u-form-item label="招聘职位">
						<u-input placeholder="职位名称" v-model="orgInfo.title"></u-input>
					</u-form-item>
					<u-form-item label="职位简介">
						<u-textarea v-model="orgInfo.desc" placeholder="职位简要介绍" autoHeight></u-textarea>
					</u-form-item>
					<u-form-item label="机构简介">
						<u-textarea v-model="orgInfo.organ_desc" placeholder="机构简要介绍" autoHeight></u-textarea>
					</u-form-item>
					<u-form-item label="机构负责人">
						<u-input placeholder="机构负责人姓名" v-model="orgInfo.contact_name"></u-input>
					</u-form-item>
					<u-form-item label="负责人电话">
						<u-input placeholder="机构负责人联系电话" v-model="orgInfo.contact_tel"></u-input>
					</u-form-item>
					<u-form-item label="机构地址">
						<u-textarea v-model="orgInfo.contact_address" placeholder="机构地址" autoHeight></u-textarea>
					</u-form-item>

					<u-form-item>
						<u-button text="发布" v-if="!orgInfo.id" type="success" @click="addForm"></u-button>
						<u-button text="保存" v-else type="success" @click="saveForm"></u-button>
					</u-form-item>
				</u-form>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		name: "",
		data() {
			return {
				
				orgInfo: {
					id:'',
					title: '',
					desc: '',
					contact_name: '',
					contact_tel: '',
					contact_address: '',
					organ_desc: '',
					remark: ''
				}
			}
		},
		onLoad(query) {
			if(query.id){
				this.orgInfo.id = query.id
				this.getRecruitmentOrgDetail(query.id)
			}
		},
		methods: {
			// 获取机构信息
			getRecruitmentOrgDetail(id){
				this.$http.getRecruitmentOrgDetail({id}).then(res=>{
					this.orgInfo = res
				})
			},
			// 编辑
			saveForm() {
				this.$http.editOrgRecruit(this.orgInfo).then(res => {
					uni.$u.toast("已保存")
					this.navigateBack()
				})
			},
			// 新增
			addForm() {
				this.$http.addOrgRecruit(this.orgInfo).then(res => {
					uni.$u.toast("已发布")
					this.navigateBack()
				})
			},
			toOrgRecruitAdd() {
				this.navigateTo('orgRecruitAdd')
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		.c-form {
			background-color: #fff;
			padding: 10rpx 20rpx;
			box-sizing: border-box;
		}


	}
</style>
